import CryptoJS from "crypto-js";

const KEY = "ykKjSimManage655"; // 密钥长度需匹配（16/24/32字节）
const IV = "86557810SimM0000"; // 16字节

export default {
  encrypt(plainText) {
    const key = CryptoJS.enc.Utf8.parse(KEY);
    const iv = CryptoJS.enc.Utf8.parse(IV);

    try {
      const encrypted = CryptoJS.AES.encrypt(
        CryptoJS.enc.Utf8.parse(plainText),
        key,
        {
          iv: iv,
          mode: CryptoJS.mode.CBC,
          padding: CryptoJS.pad.Pkcs7
        }
      );

      return encrypted.toString();
    } catch (error) {
      console.error("Encryption error:", error);
      return null;
    }
  }
};
